#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const int MAXN = 1e5 + 5;
int n,m,l,V;
int A,B,C;
int d[MAXN],v[MAXN],a[MAXN];
int p[MAXN];

struct node
{
    int l,r;
}c[MAXN];

bool over[MAXN];

bool cmp(node a,node b)
{
    if (a.r == b.r){
        return a.l < b.l;
    }return a.r < b.r;
}

void work()
{
    int cnt =0;
    for (int i=1;i <= n;i++){
        if (d[i] > p[m]){
            over[i] = 0;
            continue;
        }
        if (a[i] == 0){
            if (v[i] > V){
                over[i] = 1;
                cnt++;
            }
            else{
                over[i] = 0;
            }
        }
        else if (a[i] > 0){
            ll s = p[m] - d[i];
            ll dv = v[i]*v[i] + 2*a[i]*s;
            if (dv > 1ll*V*V){
                over[i] = 1;
                cnt++;
            }else
            {
                over[i] = 0;
            }
        }
        else {
            int x = lower_bound(p+1,p+m+1,d[i]) - p;
            ll s = p[x] - d[i];
            ll dv = v[i]*v[i] + 2*a[i]*s;
            if (dv >0 && dv > 1ll*V*V){
                over[i] = 1;
                cnt++;
            }
            else {
                over[i] = 0;
            }
        }

    }
    printf("%d ",cnt);
    int tot = 1;
    for (int i=1;i <= n;i++){
        if (!over[i]){
            continue;
        }
        if (a[i] > 0){
            double s = 1.0*(V*V - v[i]*v[i]) / 2 / a[i];
            int tots = floor(s + d[i]);
            int x = upper_bound(p+1,p+m+1,tots) - p;
            c[tot] = {x,m};
        }
        else if (a[i] == 0)
        {
            int x = lower_bound(p+1,p+m+1,d[i]) - p;
            c[tot] = {x,m};
        }
        else {
            double s = 1.0*(V*V - v[i]*v[i]) / 2 / a[i];
            int tots = ceil(s + d[i]);
            int x = lower_bound(p+1,p+m+1,tots) - p;
            int y = lower_bound(p+1,p+m+1,d[i]) - p;
            x--;
            c[tot] = {y,x};
        }
        tot++;
    }
    sort (c+1,c+tot,cmp);
    tot--;
    int ans=0;
    for (int i=1;i <= tot;){
        int r=i;
        while (r < tot && c[r+1].l <= c[i].r){
            r++;
        }
        ans++;
        i = r+1;
    }
    printf("%d\n",m-ans);
}

int main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    int t;
    scanf("%d",&t);
    while (t--)
    {
        scanf("%d%d%d%d",&n,&m,&l,&V);
        A = B = C = 1;
        for (int i=1;i <= n;i++){
            scanf("%d%d%d",&d[i],&v[i],&a[i]);
            if (a[i]) A = 0;
            if (a[i] <= 0) B = 0;
            if (a[i] >= 0) C = 0;
        }
        for (int i=1;i <= m;i++){
            scanf("%d",&p[i]);
        }

        work();
    }
    return 0;
}
